<?php

	get_header();
	
?>

        <!-- MIDDLE -->
        <section class="middle row">
		
			<?php
			
				if ( get_option( 'enable_slider_on_blog' ) )
				{
					?>
					
						<!-- TAGLINE -->
						<?php if ( get_option('tagline_text') != "" ) { echo '<div class="tagline span12"><h3>' . stripcslashes( get_option( 'tagline_text' ) ) . '</h3></div>'; } ?>
						<!-- TAGLINE -->
						
						<?php
						
							if ( get_option( 'slider_type' ) == "Big" )
							{
							?>
							   <!-- big SLIDER -->
							   <div class="flex-container main-slider main-slider-narrow span12">
							   
								  <div class="flexslider">
								  
									<ul class="slides">
									
										<?php
										
										$args_slides = array( 'post_type' => 'slides', 'posts_per_page' => -1 );
										$loop_slides = new WP_Query( $args_slides );
										
										if ( $loop_slides->have_posts() ) :
										
											while ( $loop_slides->have_posts() ) : $loop_slides->the_post();
											
												if ( get_option( $post->ID . 'for_blog_page_slider' ) )
												{
													echo '<li>';
												
														if ( has_post_thumbnail() )
														{
															$image_link = get_post_meta( $post->ID, 'image_link', true );
															$image_new_window = get_post_meta( $post->ID, 'image_new_window', true );
															
															if ( $image_link )
															{
																?><a <?php if ($image_new_window) echo 'target="_blank"' ?> href="<?php echo $image_link; ?>"><?php the_post_thumbnail( 'full', array( 'alt' => get_the_title(), 'title' => "" ) ); ?></a><?php
															}
															else
															{
																the_post_thumbnail( 'full', array( 'alt' => get_the_title(), 'title' => "" ) );
															}
														}
														else
														{
															?><img src="<?php echo get_template_directory_uri(); ?>/img/slider/slider-placeholder.png" alt="<?php the_title(); ?>"><?php
														}
														
														$image_caption = get_post_meta( $post->ID, 'image_caption', true );
														
														if ( $image_caption )
														{
															echo '<h2 class="flex-caption">';
																echo $image_caption;
															echo '</h2>';
														}
													
													echo '</li>';
												}
												// end for_blog_page_slider
											
											endwhile;
										
										endif;
										
										wp_reset_query();
										
										?>
										
									</ul>
									
								  </div>
								  
								</div>
								<!-- end big SLIDER -->
								
							<?php
							}
							else
							{
							?>
							   <!-- small SLIDER -->
							   <div class="flex-container main-slider main-slider-narrow span8">
							   
								  <div class="flexslider">
								  
									<ul class="slides">
									
										<?php
										
										$args_slides = array( 'post_type' => 'slides', 'posts_per_page' => -1 );
										$loop_slides = new WP_Query( $args_slides );
										
										if ( $loop_slides->have_posts() ) :
										
											while ( $loop_slides->have_posts() ) : $loop_slides->the_post();
											
												if ( get_option( $post->ID . 'for_blog_page_slider' ) )
												{
													echo '<li>';
												
														if ( has_post_thumbnail() )
														{
															$image_link = get_post_meta( $post->ID, 'image_link', true );
															$image_new_window = get_post_meta( $post->ID, 'image_new_window', true );
															
															if ( $image_link )
															{
																?><a <?php if ($image_new_window) echo 'target="_blank"' ?> href="<?php echo $image_link; ?>"><?php the_post_thumbnail( 'full', array( 'alt' => get_the_title(), 'title'	=> "" ) ); ?></a><?php
															}
															else
															{
																the_post_thumbnail('full', array( 'alt'	=> get_the_title(), 'title'	=> ""));
															}
														}
														else
														{
															?><img src="<?php echo get_template_directory_uri(); ?>/img/slider/slider-placeholder.png" alt="<?php the_title(); ?>"><?php
														}
														
														$image_caption = get_post_meta( $post->ID, 'image_caption', true );
														
														if ( $image_caption )
														{
															echo '<h2 class="flex-caption">';
																echo $image_caption;
															echo '</h2>';
														}
													
													echo '</li>';
												}
												// end for_blog_page_slider
											
											endwhile;
											
										endif;
										
										wp_reset_query();
										
									?>
										
									</ul>
									
								  </div>
								  
								</div>
								<!-- end small SLIDER -->
								
								<!-- ASIDE -->
								<aside class="aside span4">
								
								<?php
								
									if ( get_option( 'hide_cta_info' ) )
									{
										if ( ! function_exists( 'dynamic_sidebar' ) || ! dynamic_sidebar( "cta_sidebar" ) ) :
										endif;
									}
									else
									{
										if ( get_option( 'cta_title' ) != "" ) { echo '<h2>' . stripcslashes( get_option( 'cta_title' ) ) . '</h2>'; }
										
										if ( get_option( 'cta_text' ) != "" ) { echo '<p>' . stripcslashes( get_option( 'cta_text' ) ) . '</p>'; }

										if ( get_option( 'cta_button_text' ) != "" )
										{
											$cta_button_color = get_option( 'cta_button_color' );
											
											if ( $cta_button_color == "White" ) { $cta_button_color_out = "btn-default"; }
											elseif ( $cta_button_color == "Blue" ) { $cta_button_color_out = "btn-primary"; }
											elseif ( $cta_button_color == "Sky Blue" ) { $cta_button_color_out = "btn-info"; }
											elseif ( $cta_button_color == "Green" ) { $cta_button_color_out = "btn-success"; }
											elseif ( $cta_button_color == "Yellow" ) { $cta_button_color_out = "btn-warning"; }
											elseif ( $cta_button_color == "Red" ) { $cta_button_color_out = "btn-danger"; }
											else { $cta_button_color_out = ""; }
											
											if ( get_option( 'cta_button_url' ) != "" ) { $cta_button_url_out = 'href="' . get_option( 'cta_button_url' ) . '"'; }
										
											echo '<p><a class="btn btn-large ' . $cta_button_color_out . '" ' . $cta_button_url_out . '>' . stripcslashes( get_option( 'cta_button_text' ) ) . '</a></p>';
										}
									}
								?>
								</aside>
								<!-- end ASIDE -->
								
							<?php
							}
						?>
						
					<?php
				}
			?>
		
            <!-- CONTENT -->
            <div class="<?php if ( ! get_option( 'full_width_blog' ) ) { echo 'span8'; } else { echo 'span12'; } ?> content">
				
                <!-- PAGE HEADER -->
                <div class="page-header">
				
					<h1>
					
						<b><?php single_post_title(); ?></b>
						
						<small><?php echo get_post_meta( get_option( 'page_for_posts', true ), 'page_subtitle', true ); ?></small>
						
					</h1>
					
				</div>
                <!-- end PAGE HEADER -->
				
                <!-- POST-LIST -->
                <div class="post-list">
				
				<?php
				
					if ( have_posts() ) :
						
						while ( have_posts() ) : the_post();
						
						?>
						
							<!-- POST -->
							<article class="post row">
							
							<?php
							
								if ( has_post_thumbnail() )
								{
									?>
									
										<div class="media-box <?php if ( get_option( 'blog_layout_type' ) == "Layout 2" ) { echo 'span8'; } else { echo 'span3'; } ?>">
										
											<?php
											
												if ( get_option( 'blog_layout_type' ) == "Layout 2" )
												{
													if ( get_option( 'no_crop_blog_page2' ) )
													{
														the_post_thumbnail( 'full', array( 'alt' => get_the_title(), 'title' => "" ) );
													}
													else
													{
														the_post_thumbnail( 'blog_layout_2_img', array( 'alt' => get_the_title(), 'title' => "" ) );
													}
												}
												else
												{
													if ( get_option( 'no_crop_blog_page' ) )
													{
														the_post_thumbnail( 'full', array( 'alt' => get_the_title(), 'title' => "" ) );
													}
													else
													{
														the_post_thumbnail( 'blog_layout_1_img', array( 'alt' => get_the_title(), 'title' => "" ) );
													}
												}
											?>
											
											<div class="mask">
												<a href="<?php the_permalink(); ?>" class="ico link"></a>
												<h3 class="title"><?php echo __( 'SEE FULL POST', 'responsy' ); ?></h3>
											</div>
											
										</div>
										
									<?php
								}
								?>
								
								<div class="<?php if ( get_option( 'blog_layout_type' ) == "Layout 2" ) { if ( ! get_option( 'full_width_blog' ) ) { echo 'span8'; } else { echo 'span12'; } } else { if ( has_post_thumbnail() ) { if ( ! get_option( 'full_width_blog' ) ) { echo 'span5'; } else { echo 'span9'; } } else { if ( ! get_option( 'full_width_blog' ) ) { echo 'span8'; } else { echo 'span12'; } } } ?>">
									
									<h2 class="post-title clearfix"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><span class="category"><?php the_category(', '); ?></span></h2>
									
									<?php
									
										if ( ! get_option( 'hide_post_infos_on_blog' ) )
										{
										?>
											<div class="info">
												<i><?php echo __( 'by', 'responsy' ); ?></i> <a href="<?php echo home_url(); ?>?author=<?php the_author_meta( 'ID' ); ?>" class="author"><?php the_author(); ?></a> <i><?php echo __( 'on', 'responsy' ); ?></i> <span class="date"><?php the_date(); ?></span> <i><?php echo __( 'with', 'responsy' ); ?></i> <?php comments_popup_link( '0', '1', '%' ); ?> <i><?php echo __( 'comments', 'responsy' ); ?></i>
											</div>
										<?php
										}
									?>
									
									<?php 
										if ( get_option( 'the_excerpt_on_off' ) )
										{
											?>
												<div><?php the_content(); ?></div>
											<?php
										}
										else
										{
											$readmore_btn_color_on_blog = get_option( 'readmore_btn_color_on_blog' );
											
											if ( $readmore_btn_color_on_blog == "White" ) { $readmore_btn_color_on_blog_out = "btn-default"; }
											elseif ( $readmore_btn_color_on_blog == "Blue" ) { $readmore_btn_color_on_blog_out = "btn-primary"; }
											elseif ( $readmore_btn_color_on_blog == "Sky Blue" ) { $readmore_btn_color_on_blog_out = "btn-info"; }
											elseif ( $readmore_btn_color_on_blog == "Green" ) { $readmore_btn_color_on_blog_out = "btn-success"; }
											elseif ( $readmore_btn_color_on_blog == "Yellow" ) { $readmore_btn_color_on_blog_out = "btn-warning"; }
											elseif ( $readmore_btn_color_on_blog == "Red" ) { $readmore_btn_color_on_blog_out = "btn-danger"; }
											else { $readmore_btn_color_on_blog_out = ""; }
											
											?>
												<div><?php the_excerpt(); ?></div>
												
												<p><a href="<?php the_permalink(); ?>" class="btn <?php echo $readmore_btn_color_on_blog_out; ?>"><?php echo __( 'continue reading ...', 'responsy' ); ?></a></p>
											<?php
										}
									?>
									
									<div class="tags"><i><?php if ( get_the_tags() != "" ) { echo __( 'Tags:', 'responsy' ); } ?></i> <?php the_tags( '', ', ', '' ); ?></div>
									
								</div>
								
							</article>
							<!-- end POST -->
							
						<?php
						
						wp_link_pages();
						
						endwhile;
						
						echo '<div class="pagination-wrap">';
							oxo_pagination( array() );
						echo '</div>';
						
					endif;
					
					wp_reset_query();
					
				?>
				
                </div>
                <!-- end POST-LIST -->
				
            </div>
            <!-- end CONTENT -->
			
            <!-- SIDEBAR -->
			
			<?php
			
				if ( ! get_option( 'full_width_blog' ) )
				{
					get_sidebar();
				}
				
			?>
			
            <!-- end SIDEBAR -->
			
        </section>
        <!-- end MIDDLE -->
		
    </div>
    <!-- end CONTAINER -->

<?php

	get_footer();
	
?>